<script setup>
import { RouterView } from 'vue-router'
</script>

<template>
  <el-container class="app-wrapper">
    <el-aside width="200px" class="sidebar">
      <el-menu
        default-active="1"
        class="el-menu-vertical"
        :router="true"
      >
        <el-menu-item index="/">
          <el-icon><House /></el-icon>
          <span>首页</span>
        </el-menu-item>
        <el-sub-menu index="table">
          <template #title>
            <el-icon><Grid /></el-icon>
            <span>表结构管理</span>
          </template>
          <el-menu-item index="/table/list">表列表</el-menu-item>
          <el-menu-item index="/table/create">创建表</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="permission">
          <template #title>
            <el-icon><Lock /></el-icon>
            <span>权限管理</span>
          </template>
          <el-menu-item index="/permission/users">用户管理</el-menu-item>
          <el-menu-item index="/permission/roles">角色管理</el-menu-item>
          <el-menu-item index="/permission/apply">权限申请</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="audit">
          <template #title>
            <el-icon><Search /></el-icon>
            <span>查询审计</span>
          </template>
          <el-menu-item index="/audit/queries">查询记录</el-menu-item>
          <el-menu-item index="/audit/analysis">审计分析</el-menu-item>
        </el-sub-menu>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header height="60px" class="header">
        <div class="header-left">
          <h2>Doris数仓授权管理平台</h2>
        </div>
        <div class="header-right">
          <el-dropdown>
            <span class="user-profile">
              <el-avatar size="small" />
              <span>管理员</span>
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>个人信息</el-dropdown-item>
                <el-dropdown-item>修改密码</el-dropdown-item>
                <el-dropdown-item divided>退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </el-header>
      <el-main>
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<style scoped>
.app-wrapper {
  height: 100vh;
}

.sidebar {
  background-color: #304156;
  height: 100%;
}

.el-menu {
  border-right: none;
}

.header {
  background-color: #fff;
  border-bottom: 1px solid #dcdfe6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.header-right {
  display: flex;
  align-items: center;
}

.user-profile {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.user-profile span {
  margin-left: 8px;
}
</style>